package com.ym.fallback;

import com.ym.feign.UserInterface;
import com.ym.response.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class DefaultUserFallback implements FallbackFactory<UserInterface> {
    @Override
    public UserInterface create(Throwable cause) {
        return () -> {
            log.error("服务调用失败，触发降级: {}", cause.getMessage(), cause);
            return Result.fail(500,"服务不可用，已降级");
        };
    }
}
